package com.antdesignbackend.backend.common;

import org.springframework.data.redis.core.RedisTemplate;

import java.util.HashMap;
import java.util.Map;

public class ProxyUtil {
    private RedisTemplate redisTemplate;

    public ProxyUtil(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    public Map<String, String> GetProxy() {
        Map<String, String> map = new HashMap<>();
        Object proxyIp = redisTemplate.opsForValue().get("proxyIp");
        if (proxyIp instanceof String) {
            String proxyIpStr = (String) proxyIp;
            String ip = proxyIpStr.split(":")[0];
            String port = proxyIpStr.split(":")[1];

            map.put("proxyIp", ip);
            map.put("proxyPort", port);
            return map;
        }
        return null;
    }

}
